package com.xindaoapp.happypet.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.view.RoundImageView2;

/** @author Yangqing 选择相册等的布局 */
public class SelectAdapter extends BaseAdapter {
    private final ArrayList<Integer> resIds = new ArrayList<Integer>();
    private final ArrayList<String> descs = new ArrayList<String>();
    private final Context context;

    public SelectAdapter(Context context) {
        this.context = context;
        resIds.add(R.drawable.go_pick_picture_mid);
        // resIds.add(R.drawable.go_pick_video_mid);
        // resIds.add(R.drawable.icon_score_ad_photo);
        descs.add("图片");
        // descs.add("视频");
        // descs.add("引用帖子");
    }

    @Override
    public int getCount() {
        return resIds.size();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.note_picture_gridview_item, null);
        RoundImageView2 pictureView = (RoundImageView2) convertView.findViewById(R.id.picture);
        TextView tv_grid_desc = (TextView) convertView.findViewById(R.id.tv_grid_desc);
        // LayoutParams params =
        // new LayoutParams(CommonUtil.dip2px(PostDetailActivity.this, 180) / 2,
        // CommonUtil.dip2px(PostDetailActivity.this, 160) / 2);
        // pictureView.setLayoutParams(params);

        pictureView.setImageDrawable(null);
        pictureView.setBackgroundResource(resIds.get(position));
        tv_grid_desc.setVisibility(View.VISIBLE);
        tv_grid_desc.setText(descs.get(position));
        return convertView;
    }

    @Override
    public Object getItem(int position) {
        return resIds.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
